package com.morn.fanfou;

import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import com.morn.fanfou.api.Fanfou;
import com.morn.fanfou.model.User;

public class FanfouApplication extends Application {

	private Fanfou fanfou;

	@Override
	public void onCreate() {
		super.onCreate();
		registerReceiver();

	}

	public BroadcastReceiver connectionChangeRecevier = new BroadcastReceiver() {

		@Override
		public void onReceive(Context context, Intent intent) {
			ConnectivityManager connectivityManager = (ConnectivityManager) context
					.getSystemService(Context.CONNECTIVITY_SERVICE);
			NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
			if (networkInfo != null) {
				int type = networkInfo.getType();
				switch (type) {
				case ConnectivityManager.TYPE_MOBILE:
					break;

				case ConnectivityManager.TYPE_WIFI:
					break;
				}
			}
		}

	};

	private void registerReceiver() {
		IntentFilter intentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
		this.registerReceiver(connectionChangeRecevier, intentFilter);

	}

	public Fanfou getFanfou() {
		if (this.fanfou == null) {
			this.fanfou = new Fanfou(this);
		}
		return this.fanfou;
	}

	public boolean isMySelf(String userId) {
		return false;
	}

	@Override
	public void onTerminate() {

	}

	@Override
	public void onConfigurationChanged(Configuration newConfig) {

	}

	@Override
	public void onLowMemory() {

	}

}
